package com.wcards.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wcards.service.AdoptRecordInfoService;
import com.wcards.config.R;
import com.wcards.entity.AdoptRecordInfo;
import com.wcards.mapper.AdoptRecordInfoMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/*
领养记录表
 */
@Service
public class AdoptRecordInfoServiceImpl extends ServiceImpl<AdoptRecordInfoMapper, AdoptRecordInfo> implements AdoptRecordInfoService {
    @Autowired
    private AdoptRecordInfoMapper adoptRecordInfoMapper;
    @Override
    public R<List<AdoptRecordInfo>> listByUid(HttpServletRequest request,Integer userId) {

        QueryWrapper<AdoptRecordInfo> wrapper=new QueryWrapper<>();
        //通过session中的id查询领养记录
        wrapper.eq("user_id",userId);
        List<AdoptRecordInfo> adoptRecordInfos = adoptRecordInfoMapper.selectList(wrapper);
        return R.success(adoptRecordInfos);
    }
}
